﻿<Window x:Class="Bazookabird.Wpf.Queries.QueryListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Client="clr-namespace:Microsoft.TeamFoundation.WorkItemTracking.Client;assembly=Microsoft.TeamFoundation.WorkItemTracking.Client"
             xmlns:cal="http://www.caliburnproject.org" mc:Ignorable="d" 
             Height="200" Width="500"
             WindowStyle="ToolWindow"
             Title="{Binding DisplayName}">
    <Window.Resources>
        <HierarchicalDataTemplate DataType="{x:Type Client:QueryFolder}" ItemsSource="{Binding Path=DataContext, RelativeSource={RelativeSource Self}, FallbackValue=''}">
            <TextBlock Text="{Binding Name}" FontStyle="Italic" />
        </HierarchicalDataTemplate>
        <DataTemplate DataType="{x:Type Client:QueryDefinition}">
            <TextBlock Text="{Binding Name}" />            
        </DataTemplate>
        <DataTemplate x:Key="QueryHandlerTemplate">
            <TextBlock Text="{Binding Name}" />
        </DataTemplate>
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <TreeView Grid.Column="2" ItemsSource="{Binding QueryHierarchy, FallbackValue=''}"
              cal:Message.Attach="[Event SelectedItemChanged] = [Action TreeViewSelectedItemChanged($source, $eventArgs)]"
              ScrollViewer.HorizontalScrollBarVisibility="Hidden"
              Background="Transparent" />
        <GridSplitter Grid.Column="1" Width="4" VerticalAlignment="Stretch" ResizeBehavior="PreviousAndNext" ResizeDirection="Columns" />
        <ListBox Grid.Column="0" 
                 HorizontalAlignment="Stretch"
                 ItemsSource="{Binding QueryHandlers}" 
                 SelectedItem="{Binding SelectedQueryHandler}" 
                 Background="Transparent"                  
                 ItemTemplate="{StaticResource QueryHandlerTemplate}" 
                 ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                 VerticalAlignment="Stretch" />
        <Button Name="AddQueryHandler" Content="Add view" Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" Width="100" />
    </Grid>
</Window>